<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/core" prefix="c"%>
<%@ taglib uri="/tags/fmt" prefix="fmt"%>
<html:form action="/insertInstructionsFutures"  onsubmit="return validateSubmit(this.form);">	
	<script type="text/javascript">
		function validateSubmit(forma){
			var lista = forma.instructionsFuturesView;
			alert("size: " + lista.length);
			var quantity = forma.instructionsFuturesView;
			var price = forma.instructionsFuturesView.price;
			
			for( var int_i = 0; int_i < lista.length; int_i++ ){
				errors = "";
				alert('Quantity: '+ lista[int_i].value);		
			}
			return false;
		}
	</script>
	<br />
	<table width="450px" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
		<tr>
			<td align="left" class="titulocolumna">
				<bean:message key="label.purchases.instructions.label"/>
			</td>
		</tr>
	</table>
	<br />
	<table width="450px" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
		<tr>
			<td class="etiqueta_campo_center">
				<bean:message key="menu.module.corn.sub.future"/>
			</td>
			<td class="etiqueta_campo_center">
				<bean:message key="label.purchases.instructions.futures.price"/>												
			</td>
			<td class="etiqueta_campo_center">
				<bean:message key="label.purchases.instructions.futures.furchase.period"/>
			</td>
			<td class="etiqueta_campo_center">
				<bean:message key="label.purchases.instructions.futures.furchase.application"/>												
			</td>
			<td class="etiqueta_campo_center">
				<bean:message key="label.purchases.instructions.futures.minor.price"/>												
			</td>
			<td class="etiqueta_campo_center">
				<bean:message key="label.purchases.instructions.futures.stoploss"/>								
			</td>						
		</tr>		
		<logic:notEmpty name="InstructionsFuturesForm" property="instructionsFuturesView">
			<logic:iterate id="row" name="InstructionsFuturesForm" property="instructionsFuturesView" indexId="int_i">
				<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">
					<html:hidden name="row" property="purchaseInstructionFutureId"/>
					<html:hidden name="row" property="purchaseInstructionDetailId"/>					
					<td align="center">					
						<input type="text" style="text-align: right;" name='instructionsFuturesView[<c:out value="${int_i}"/>].quantity' onfocus="this.select();" value='<c:out value="${row.quantity}"/>' class="campo_texto" onfocus="this.select();" onkeydown="return (numeric(event, 0) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);" size="3">
					</td>
					<td align="center">						
						<input type="text" style="text-align: right;" name='instructionsFuturesView[<c:out value="${int_i}"/>].price' onfocus="this.select();" value='<c:out value="${row.price}"/>' class="campo_texto" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);" size="3">
					</td>
					<td align="center">															
						<select name='instructionsFuturesView[<c:out value="${int_i}"/>].accountFuturePeriodId' class="campo_texto" >							
							<c:forEach var="row" items="${InstructionsFuturesForm.accountPeriod}">
								<option value='<c:out value="${row.periodId}" />' > <c:out value="${row.periodName}" />'</option>
							</c:forEach>
						</select>													
					</td>
					<td align="center">	
						<select name='instructionsFuturesView[<c:out value="${int_i}"/>].applicationFuturePeriodId' class="campo_texto" >							
							<c:forEach var="row" items="${InstructionsFuturesForm.accountPeriod}"> 								
								<option value='<c:out value="${row.periodId}" />' > <c:out value="${row.periodName}" />'</option>
							</c:forEach>
						</select>										
					</td>
					<td align="center">
					  <select name='instructionsFuturesView[<c:out value="${int_i}"/>].miniorPrice' class="campo_texto" >
					  	<option value="Y" label='<bean:message key="label.common.yes" />'>
					  	<option value="N" label='<bean:message key="label.common.no" />'>					  							
					  </select>					  					  
					</td>
					<td align="center">						
						<input type="text" name='instructionsFuturesView[<c:out value="${int_i}"/>].stopLoss' onfocus="this.select();" value='<c:out value="${row.stopLoss}"/>' style="text-align: right;" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);" class="columnanumero" size="3" />						
					</td>
				</tr>	
			</logic:iterate>
		</logic:notEmpty>		
	</table>		
	<br />
	<html:submit value="guardar" onclick="return validateSubmit(this.form);"></html:submit>
</html:form>
